package com.scenic.rd_android.testview.ratingbar;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.RatingBar;

import com.nova.scenic.projectlibs.util.debug.MyLog;

/**
 * Created by scenic on 16/5/27.
 */
public class CustomRatingBar extends RatingBar {
    private static final String TAG = "CustomRatingBar";

    public CustomRatingBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public CustomRatingBar(Context context, AttributeSet attrs) {
        super(context, attrs);

        MyLog.i(TAG,"CustomRatingBar");
//        setThumbOffset(500);
//        setThumb(getResources().getDrawable(R.mipmap.ic_launcher));

//        setProgressDrawable(getResources().getDrawable(R.mipmap.ic_launcher));
//        ActivityShowUtils.showImageView(context,getProgressDrawable());

//        setRating(3);

//        setProgress(1);

//        setSecondaryProgress(3);



    }

    public CustomRatingBar(Context context) {
        super(context);
    }



    @Override
    protected synchronized void onDraw(Canvas canvas) {
//        LayerDrawable drawable = (LayerDrawable) getProgressDrawable();
//
//        setDraw(drawable.findDrawableByLayerId(android.R.id.background),canvas);
//
//
//        Drawable sencoder = drawable.findDrawableByLayerId(android.R.id.secondaryProgress);
//        sencoder.setBounds(0,0,0,0);
//        sencoder.draw(canvas);
//
//
//        Drawable process = drawable.findDrawableByLayerId(android.R.id.progress);
//        process.setBounds(0,0,0,0);
//        process.draw(canvas);


        super.onDraw(canvas);


    }

    void setDraw(Drawable drawable,Canvas canvas){
        drawable.setBounds(0,0,1000,300);
        drawable.draw(canvas);
    }

    @Override
    protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int size = MeasureSpec.getSize(widthMeasureSpec);
        MyLog.i(TAG,"width size is " + size);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
}
